package com.alibaba.nacos.config.server.jpa.entity;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Type;

/**
 * @author
 * @date 2020-03-08 23:31
 *
 */
@Entity
@Table(name = "NACOS_USERS",uniqueConstraints = {
    @UniqueConstraint(name="UK_USERNAME", columnNames = "USERNAME")
})
public class UsersEntity extends AbstractEntity {

    private static final long serialVersionUID = 1L;

    @Column(name = "ENABLED", nullable = false)
    @Type(type = "true_false")
    private Boolean enabled;

    @Column(name = "PASSWORD", nullable = false, length = 500)
    private String password;

    @Column(name = "USERNAME", nullable = false)
    private String username;

    public UsersEntity () {}


    public UsersEntity(String username,Boolean enabled, String password) {
        this.enabled = enabled;
        this.password = password;
        this.username = username;
    }

    public UsersEntity setEnabled(Boolean enabled){
        this.enabled = enabled;
        return this;
    }

    public Boolean getEnabled(){
        return enabled;
    }

    public UsersEntity setPassword(String password){
        this.password = password;
        return this;
    }

    public String getPassword(){
        return password;
    }

    public UsersEntity setUsername(String username){
        this.username = username;
        return this;
    }

    public String getUsername(){
        return username;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("UsersEntity = {");

        if (enabled != null){
            sb.append("enabled = ").append(enabled).append(", ");
        }
        if (password != null){
            sb.append("password = ").append(password).append(", ");
        }
        if (username != null){
            sb.append("username = ").append(username);
        }

        sb.append("}");
        return sb.toString();
    }

}
